package com.hnkywl.sts.action.base;

import com.hnkywl.sts.entity.base.Dxpz;
import com.hnkywl.sts.entity.base.Jkpz;
import com.hnkywl.sts.service.base.DxpzService;
import com.hnkywl.sts.service.base.JkpzService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-5-20
 * Time: 下午8:51
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/base/jkpz")
public class JkpzAction extends SimpleActionSupport {
    private JkpzService jkpzService;
    private String bm;
    //分页组件 起始位置
    private int page;
    //分页组件 页面大小
    private int rows = 10;

    private Jkpz jkpz;

    private Long jkpzId;

    @Action("jkpzList")
    public void jkpzList() {
        this.renderJson(this.jkpzService.findJkpzList(bm, page, rows));
    }

    @Action("jkpz_content")
    public String jkpzContent() {
        return SUCCESS;
    }


    @Action("add_jkpz")
    public void addJkpz() {
        try {
            this.jkpzService.addJkpz(jkpz);
            renderText("{\"statusCode\":\"200\", \"message\":\"新增成功！\", \"operationType\":\"update\"}");
        } catch (RuntimeException e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }

    @Action("change_jkpz")
    public void changeJkpz() {
        try {
            this.jkpzService.changeJkpz(jkpzId);
            renderText("{\"statusCode\":\"200\", \"message\":\"修改状态成功！\"}");
        } catch (RuntimeException e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }

    public Long getJkpzId() {
        return jkpzId;
    }

    public void setJkpzId(Long jkpzId) {
        this.jkpzId = jkpzId;
    }

    public Jkpz getJkpz() {
        return jkpz;
    }

    public void setJkpz(Jkpz jkpz) {
        this.jkpz = jkpz;
    }

    public String getBm() {
        return bm;
    }

    public void setBm(String bm) {
        this.bm = bm;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    @Autowired
    public void setJkpzService(JkpzService jkpzService) {
        this.jkpzService = jkpzService;
    }
}
